package com.axc.gallery2.edit.effective;

import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.BlurMaskFilter;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ComposeShader;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.RadialGradient;
import android.graphics.Shader;
import android.graphics.Bitmap.Config;
import android.graphics.BlurMaskFilter.Blur;
import android.graphics.Shader.TileMode;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RectShape;

public class ToColW_Yellow {
	Bitmap bitmap = null;
	int width = 0;
	int height = 0;
	BlurMaskFilter blurMaskFilter;
	Paint paint = null;
	Shader mBitmapShader = null;
	ShapeDrawable shapeDrawable = null;
	Canvas canvas;

	/* 线性渐变渲染 
	Shader mLinearGradient = null;
	*/
	
	/* 混合渲染 */
	Shader mComposeShader = null;
	/* 唤醒渐变渲染 */

	Shader mRadialGradient = null;
	/* 梯度渲染 */

	Shader mSweepGradient = null; 
	public Bitmap ProcessWork(Bitmap bmp,int x,int y) {
		blurMaskFilter = new BlurMaskFilter(50, Blur.SOLID);
		bitmap = bmp;
		width = bitmap.getWidth();
		height = bitmap.getHeight();
		bitmap=new ToZoomImage().ProcessImage(bitmap, 360, 480);

		/* 构建RadialGradient对象，设置半径的属性 */

		// x,y 半径,颜色 （TitleMode）显示模式 {1CLAMP 复制边缘颜色如果材质吸引它原来的范围之外,2MIRROR
		// 镜像重复,3REPEAT 重复图像}
		
		//渐变光圈效果一
		mRadialGradient = new RadialGradient(x , y , 150,
				new int[] { Color.WHITE, Color.YELLOW }, null,
				Shader.TileMode.CLAMP);

		// TODO Auto-generated constructor stub
		mBitmapShader = new BitmapShader(bitmap, TileMode.REPEAT,
				TileMode.MIRROR);

		// 混合模式
		mComposeShader = new ComposeShader(mBitmapShader, mRadialGradient,
				PorterDuff.Mode.DARKEN);
		paint = new Paint();
		Bitmap bitmap2=Bitmap.createBitmap(360,480,Config.RGB_565);//bitmap.getWidth(), bitmap.getHeight(), Config.RGB_565);
		canvas=new Canvas(bitmap2);
		
		
		//Canvas 画图开始
		shapeDrawable = new ShapeDrawable(new RectShape());
		shapeDrawable.getPaint().setShader(mBitmapShader);
		shapeDrawable.setBounds(0, 0, width, height);

		shapeDrawable.draw(canvas);
		
		paint.setShader(mComposeShader);
		paint.setMaskFilter(blurMaskFilter);

		canvas.drawRect(0, 0, width	, height, paint);
		
		return bitmap2;
	}
}
